﻿
using System;
using System.Collections.Generic;

namespace WaterResources
{
    class WaterSecurity : IWaterResourcesDb
    {
        public int Id { get; set; }
        public int Level { get; set; }
        public string Levelname { get; set; }
        public string Name { get; set; }
        public string Area { get; set; }
        public string Start { get; set; }
        public string End { get; set; }
        public decimal RiverWidth { get; set; }
        public decimal Elevation { get; set; }
        public decimal Ratio { get; set; }
        public decimal Line { get; set; }
        public decimal Allow { get; set; }
        public decimal Safe { get; set; }
        public decimal Depth { get; set; }
        public decimal ChannelWidth { get; set; }
        public decimal Threshold { get; set; }
        public string Dredging { get; set; }
        public DateTime Time { get; set; }

        public IList<string> GetCols()
        {

            return new List<string>
            {
                "编号",
                "河道防洪排涝等级",
                "河道名称",
                "河道所属辖区",
                "河道起点",
                "河道终点",
                "河道宽度(m)",
                "边坡比",
                "设计河底高程(m)",
                "设计洪水水位(m)",
                "是否允许浪爬高",
                "安全超高(m)",
                "淤积深度(m)",
                "河槽宽度(m)",
                "淤积阈值(m)",
                "清淤判断",
                "录入时间",
            };
        }

        public IList<string> GetMaps()
        {

            return new List<string>
            {
                Id.ToString(), // 编号
                Level.ToString(), // 河道防洪排涝等级
                Levelname, // 河道防洪排涝等级
                Name, // 河道名称
                Area, // 河道所属辖区
                Start, // 河道起点
                End, // 河道终点
                RiverWidth.ToString("N2"), // 河道宽度(m)
                Ratio.ToString(), // 边坡比
                Elevation.ToString("N2"), // 设计河底高程(m)
                Line.ToString("N2"), // 设计洪水水位(m)
                Allow==1?"是":Allow==0?"否":"自定义", // 是否允许浪爬高
                Safe.ToString("N2"), // 安全超高(m)
                Depth.ToString("N2"), // 淤积深度(m)
                ChannelWidth.ToString("N2"), // 河槽宽度(m)
                Threshold.ToString("N2"), // 淤积阈值(m)
                Dredging, // 清淤判断
                Time.ToString("F"), // 录入时间
            };
        }
        
        public string GetFindSql()
        {
            return "select id, level, name, area, start, end, river_width riverWidth, ratio, elevation, line, allow, safe, depth, channel_width channelWidth, threshold, dredging, time from water_security";
        }

        public string GetSaveSql()
        {
            return @"insert into 
water_security(level, name, area, start, end, river_width, elevation, ratio, line, allow, safe, depth, channel_width, threshold, dredging, time) 
values(@Level, @Name, @Area, @Start, @End, @RiverWidth, @Elevation, @Ratio, @Line, @Allow, @Safe, @Depth, @ChannelWidth, @Threshold, @Dredging, @Time)";
        }

        public string GetEditSql()
        {
            return @"update water_security set 
level=@Level, name=@Name, area=@Area, start=@Start, end=@End, river_width=@RiverWidth, elevation=@Elevation, ratio=@Ratio, 
line=@Line, allow=@Allow, safe=@Safe, depth=@Depth, channel_width=@ChannelWidth, threshold=@Threshold, dredging=@Dredging, time=@Time
where id=@Id";
        }

        public string GetDropSql()
        {
            return @"delete from water_security where id=@Id";
        }
    }
}
